home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 905 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: "Nathan Myers, http://www.cantrip.org/" <ncm@cantrip.org>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: template and const
  5. Date: 29 Mar 1996 16:09:53 GMT
  6. Organization: The Cantrip Cooperative
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <315B306B.5271C407@cantrip.org>
  9. References: <AD8043589668101EA@sleipner.nts.mh.se>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset="us-ascii"
  13. Content-Transfer-Encoding: 7bit
  14. X-Nntp-Posting-Host: ncm.vip.best.com
  15. X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i386)
  16. X-Lines: 25
  17. Content-Length: 843
  18. Originator: clamage@taumet
  19.  
  20. Lars Farm <lars.farm@nts.mh.se> wrote:
  21. > Is "pair<T1,T2>" valid as function argument where the
  22. > declaration expects "const pair<const T1,T2>&"?
  23.  
  24. [It would allow: ]
  25. > void f( string a, string b )
  26. > {
  27. >     map<string,string> m;
  28. >     ...
  29. >     m.insert( make_pair(a,b) ); // valid c++?  [yes, now.]
  30.  
  31. The definition of the template pair<> was changed at the March '96
  32. meeting specifically to allow this. 
  33.  
  34. pair<> now has a template constructor.  Of course that is of little
  35. use to you (for now) if you (like most of us) don't yet have a compiler
  36. that supports member templates.  In the meantime you might like to 
  37. write a little template function, make_map_pair<>().
  38.  
  39. If we had type deduction from constructor arguments, even make_pair<>()
  40. would be unnecessary.   Next time, next time.
  41.  
  42. Nathan Myers
  43. ncm@cantrip.org  http://www.cantrip.org/
  44.  
  45.  
  46. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  47. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  48. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  49. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  50. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  51.